package com.aaa.controller;


import com.aaa.entity.CourseIntroduce;
import com.aaa.entity.EduCourse;
import com.aaa.service.ICourseIntroduceService;
import com.aaa.service.IEduCourseService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.time.LocalDate;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zyd
 * @since 2021-03-24
 */
@RestController
@RequestMapping("/edu-course")
public class EduCourseController {
    @Resource
    private IEduCourseService iEduCourseService;
    @Resource
    private ICourseIntroduceService introduceService;

    /**
     * 分页和模糊查询
     * @param page
     * @param course
     * @return
     */
    @PostMapping("/queryAll")
    public Page queryAll(Page page, EduCourse course){
//        System.out.println("111111111111111");
        return iEduCourseService.queryAll(page,course);
    }
    /**
     * 修改
     */
    @PostMapping("/upd")
    public  boolean upd(EduCourse course, CourseIntroduce courseIntroduce){
        courseIntroduce.setGmtModified(LocalDate.now());
        return  iEduCourseService.updateById(course)&&introduceService.updateById(courseIntroduce);
    }
    /**
     * 上下架问题按钮
     */
    @PostMapping("upStatus")
    public boolean upStatus(EduCourse course){
        return iEduCourseService.updateById(course);
    }


    @GetMapping("/loboQuery")
    public List<Map> loboQuery( Integer status){
        return iEduCourseService.loboQuery(status);
    }
 }

